package com.yuan.controller.background;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuan.bean.LibraryCard;
import com.yuan.mapper.LibraryCardMapper;
import com.yuan.service.LibraryCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BorrowHistoryController {

    @Autowired
    LibraryCardService libraryCardService;

    //查询所有用户的借书记录
    @ResponseBody
    @GetMapping("/selectAll")
    public PageInfo<LibraryCard> selectAll(@RequestParam(defaultValue = "1",value = "pageNum")Integer pageNum,
                                           @RequestParam(defaultValue = "",value ="userName")String userName){
        PageHelper.startPage(pageNum,5);
        final List<LibraryCard> libraryCards = libraryCardService.selectAll(userName);
        PageInfo<LibraryCard> pageInfo=new PageInfo<>(libraryCards);
        return pageInfo;
    }


}
